package com.tiancheng.onecode.trade.enums;

import com.tiancheng.onecode.enums.BaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 支付方式
 */
@Getter
@AllArgsConstructor
public enum PayWayEnum implements BaseEnum<String> {
    WECHAT("wechat", "微信"),
    ALIPAY("alipay", "支付宝"),
    UNIONPAY("unionpay", "银联"),
    POINTS("points", "积分支付"),
    DEDUCTION("deduction", "抵扣"),
    ;

    private final String code;
    private final String desc;

    public static String getDesc(String code) {
        Optional<PayWayEnum> found = Arrays.stream(PayWayEnum.values()).filter(c -> c.code.equals(code)).findFirst();
        if (found.isPresent()) {
            return found.get().getDesc();
        }
        return "";
    }
}
